<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="base" uri="http://qdbp.gitee.io/tags/base/"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<link href="<base:url href='assets/pc/basedata/settings/config.core.css'/>" rel="stylesheet" type="text/css" />

<table class="x-datagrid main-datalist"
		data-options="toolbar:'.toolbar-box',fitColumns:true,nowrap:false,
		method:'POST',url:'<base:url href='actions/config-item/manager/list.json' />',
		fixedParams:{ordering:'configKey asc'<shiro:lacksPermission name="root:develop">,visible:true,usingState:'ENABLED'</shiro:lacksPermission>},
		eachCopy: { displayText:'this.configText||this.configValue' },
		idField:'id', xextra:true">
	<thead>
		<tr>
			<th data-options="field:'id',width:100,align:'center',checkbox:true">选择</th>
			<th data-options="field:'configName',width:200,align:'center',xpopup:'set-value',xoptions:{fillData:false,onAfterFillData:onSetValueFillData}">名称</th>
			<th data-options="field:'configKey',width:200,align:'center'">KEY</th>
			<th data-options="field:'displayText',width:400,align:'center'">配置内容</th>
			<th data-options="field:'configDesc',width:500,align:'center'">描述</th>
		</tr>
	</thead>
</table>

<div class="hide">

	<div class="toolbar-box">
		<form>
			<div class="toolbar-item">
				<input type="hidden" name="deptCodeStarts" />
				<span class="toolbar-text">名称:</span><input type="text" name="configNameLike" class="x-textbox panel-input"/>
				<span class="toolbar-text">KEY:</span><input type="text" name="configKeyLike" class="x-textbox panel-input"/>
				<span class="toolbar-text">描述:</span><input type="text" name="configDescLike" class="x-textbox panel-input"/>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'search',iconCls:'fa fa-search'">查询</a>
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'reset'<%--,iconCls:'fa fa-circle-thin'--%>">重置</a>
				<div class="clear"></div>
			</div>
			<div class="toolbar-item">
				<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'prompt',iconCls:'fa fa-question-circle'">说明</a>
				<shiro:hasPermission name="root:develop">
					<shiro:hasPermission name="system-config:manager:create">
					<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'edit',operate:'create',iconCls:'fa fa-plus',copy:{title:true,icon:true},fillData:false">创建</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="system-config:manager:update">
					<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'edit',operate:'update',selection:'single',iconCls:'fa fa-pencil',copy:{title:true,icon:true},fillData:false,onAfterFillData:onUpdateFillData">修改</a>
					</shiro:hasPermission>
					<shiro:hasPermission name="system-config:manager:delete">
					<a href="javascript:void(0)" class="x-linkbutton" data-options="xpopup:'delete',selection:'multi',iconCls:'fa fa-minus',fillData:{id:'ids',i:'.records'}">删除</a>
					</shiro:hasPermission>
				</shiro:hasPermission>
			</div>
			<div class="clear"></div>
		</form>
	</div>


	<div class="x-dialog container-fluid" title="说明" data-options="xpopup:'prompt',width:600,modal:true,iconCls:'fa fa-question-circle'">
		<div class="ptb-md text-center fz-lg">
			<div>配置项只允许在开发模式下新增/修改/删除</div>
			<div>并且在创建时指定配置值的类型, 值的校验规则, 枚举的选项等</div>
			<div>发布后管理员只能在指定范围内修改配置项的值</div>
		</div>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">关闭</a>
		</div>
	</div>
	
	<div class="x-dialog container-fluid" title="详情" data-options="xpopup:'set-value',width:800,modal:true,iconCls:'fa fa-file-text-o'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/config-item/manager/set-value.json'/>">
			<dd class="plr-lg">
				<input type="hidden" name="id" />
				<div class="form-group compact">
					<div class="col-md-2 control-label pl-clear">名称</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configName" data-options="readonly:true"/></div>
				</div>
				<div class="form-group compact">
					<div class="col-md-2 control-label pl-clear">KEY</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configKey" data-options="readonly:true"/></div>
				</div>

				<%-- 文本类型配置项 --%>
				<div class="form-group compact show-in-type show-in-text hide">
					<div class="col-md-2 control-label pl-clear"><i class="asterisk"></i>配置内容</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configValue" 
						data-options="required:true,disabled:true,validType:['textValueValidate']"/></div>
				</div>
				<div class="form-group compact show-in-type show-in-text hide">
					<div class="col-md-2 control-label pl-clear">显示值</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configText" data-options="disabled:true,prompt:'对配置内容的描述'"/></div>
				</div>
				<%-- 数字类型配置项 --%>
				<div class="form-group compact show-in-type show-in-number hide">
					<div class="col-md-2 control-label pl-clear"><i class="asterisk"></i>配置内容</div>
					<div class="col-md-9 control-input">
						<input class="x-numberbox" type="text" name="configValue" 
							data-options="required:true,disabled:true,validType:['numberValueValidate']"/>
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-number hide">
					<div class="col-md-2 control-label pl-clear">显示值</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configText" data-options="disabled:true,prompt:'对配置内容的描述'"/></div>
				</div>
				<%-- 枚举类型配置项 --%>
				<div class="form-group compact show-in-type show-in-enums hide">
					<div class="col-md-2 control-label pl-clear"><i class="asterisk"></i>配置内容</div>
					<div class="col-md-9 control-input">
						<input class="x-combobox" type="text" name="configValue" 
							data-copy-options="enums.configValueOptions"
							data-options="required:true,editable:false,disabled:true,valueField:'key',textField:'key'"/>
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-enums hide">
					<div class="col-md-2 control-label pl-clear">显示值</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configText" data-options="editable:false,disabled:true,prompt:'对配置内容的描述'"/></div>
				</div>
				<%-- 对象类型配置项 --%>
				<div class="form-group compact show-in-type show-in-object hide">
					<div class="col-md-2 control-label pl-clear"><i class="asterisk"></i>配置内容</div>
					<div class="col-md-9 control-input">
						<input class="x-comboform" type="text" name="configValue"
							data-copy-options="object.configValueOptions"
							data-options="required:true,editable:false,panelMaxHeight:'auto',separator:' | ',
							space:space,panelTemplate:'object-config-value',cls:'object-config-value'" />
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-object hide">
					<div class="col-md-2 control-label pl-clear">显示值</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configText" data-options="editable:false,disabled:true,prompt:'对配置内容的描述'"/></div>
				</div>

				<div class="form-group compact">
					<div class="col-md-2 control-label pl-clear">描述</div>
					<div class="col-md-9 control-input"><input class="x-textbox" type="text" name="configDesc" data-options="readonly:true,multiline:true,height:50"/></div>
				</div>
				<shiro:hasPermission name="root:develop">
				<div class="form-group compact">
					<div class="col-md-2 control-label pl-clear">选项</div>
					<div class="col-md-9 control-input">
						<div class="row compact">
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="checkbox" name="visible" value="1" data-def-value="1" disabled /></span>
									<div class="form-control">可见</div>
								</label>
							</div>
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="checkbox" name="editable" value="1" data-def-value="1" disabled /></span>
									<div class="form-control">可编辑</div>
								</label>
							</div>
						</div>
					</div>
				</div>
				<div class="form-group compact">
					<div class="col-md-2 control-label pl-clear">状态</div>
					<div class="col-md-9 control-input">
						<div class="row compact">
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="radio" name="usingState" value="ENABLED" data-def-value="ENABLED" disabled /></span>
									<div class="form-control">启用</div>
								</label>
							</div>
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="radio" name="usingState" value="DISABLED" disabled /></span>
									<div class="form-control">禁用</div>
								</label>
							</div>
						</div>
					</div>
				</div>
				</shiro:hasPermission>

			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="system-config:manager:set-value">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>

	<div class="x-dialog container-fluid" title="编辑" data-options="xpopup:'edit',width:1200,modal:true,iconCls:'fa fa-pencil'">
		<form class="pure-box form-horizontal" method="POST" 
				data-create-action="<base:url href='actions/config-item/manager/create.json'/>"
				data-update-action="<base:url href='actions/config-item/manager/update.json'/>">
			<dd class="plr-lg">
				<input type="hidden" name="id" />
				<div class="form-group compact">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>名称</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configName" data-options="required:true,prompt:'中文名称'"/></div>
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>KEY</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configKey" data-options="required:true,validType:['configKeyValidate'],prompt:'英文的KEY, 用于程序调用'"/></div>
				</div>

				<div class="form-group compact">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>值类型</div>
					<div class="col-md-5 control-input">
						<input class="x-combobox" type="text" name="valueType" data-options="
							required:true,editable:false,valueField:'type',textField:'name',onChange:onValueTypeChange"/>
					</div>
					<div class="col-md-1 control-label pl-clear">描述</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configDesc" data-options=""/></div>
				</div>

				<%-- 同时有use-in-object和show-in-type的会复制到对象字段列表中, 只有use-in-object的会剪切 --%>
				<%-- 文本类型配置项 --%>
				<div class="form-group compact use-in-object show-in-type show-in-text hide">
					<div class="col-md-1 control-label pl-clear">文本选项</div>
					<div class="col-md-11 control-input">
						<input class="x-comboform" type="text" name="valueMetadata"
							data-copy-options="text.metadataOptions"
							data-options="required:false,editable:false,panelMaxHeight:'auto',separator:', ',
							space:space,panelTemplate:'text-metadata',cls:'text-metadata'" />
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-text hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>默认值</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configValue" 
						data-options="required:true,disabled:true,validType:['textValueValidate']"/></div>
					<div class="col-md-1 control-label pl-clear">显示值</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configText" data-options="disabled:true,prompt:'对默认值的描述'"/></div>
				</div>

				<%-- 数字类型配置项 --%>
				<div class="form-group compact use-in-object show-in-type show-in-number hide">
					<div class="col-md-1 control-label pl-clear">数字选项</div>
					<div class="col-md-11 control-input">
						<input class="x-comboform" type="text" name="valueMetadata"
							data-copy-options="number.metadataOptions"
							data-options="required:false,editable:false,panelMaxHeight:'auto',separator:', ',
							space:space,panelTemplate:'number-metadata',cls:'number-metadata'" />
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-number hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>默认值</div>
					<div class="col-md-5 control-input">
						<input class="x-numberbox" type="text" name="configValue" 
							data-options="required:true,disabled:true,validType:['numberValueValidate']"/>
					</div>
					<div class="col-md-1 control-label pl-clear">显示值</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configText" data-options="disabled:true,prompt:'对默认值的描述'"/></div>
				</div>

				<%-- 枚举类型配置项 --%>
				<div class="form-group compact use-in-object show-in-type show-in-enums hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>枚举选项</div>
					<div class="col-md-11 control-input">
						<input class="x-combocollect" type="text" name="valueMetadata" 
							data-copy-options="enums.metadataOptions"
							data-options="required:true,validType:['itemsRequired'],editable:false,panelMaxHeight:'auto',separator:' | ',
							space:space,cls:'enums-metadata',panelTemplate:'enums-metadata',itemTemplate:'enums-item',valueField:'key',textField:'value'" />
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-enums hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>默认值</div>
					<div class="col-md-5 control-input">
						<input class="x-combobox" type="text" name="configValue" 
							data-copy-options="enums.configValueOptions"
							data-options="required:true,editable:false,disabled:true,valueField:'key',textField:'key'"/>
					</div>
					<div class="col-md-1 control-label pl-clear">显示值</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configText" data-options="editable:false,disabled:true,prompt:'对默认值的描述'"/></div>
				</div>

				<%-- 对象类型配置项 --%>
				<div class="form-group compact show-in-type show-in-object hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>对象字段</div>
					<div class="col-md-11 control-input">
						<input class="x-combocollect" type="text" name="valueMetadata" 
							data-copy-options="object.metadataOptions"
							data-options="required:true,validType:['itemsRequired'],editable:false,panelMaxHeight:'auto',separator:' | ',useFieldType:false,
							space:space,cls:'object-metadata',panelTemplate:'object-metadata',itemTemplate:'object-item',valueField:'fieldName',textField:'fieldText'" />
					</div>
				</div>
				<div class="form-group compact show-in-type show-in-object hide">
					<div class="col-md-1 control-label pl-clear"><i class="asterisk"></i>默认值</div>
					<div class="col-md-5 control-input">
						<input class="x-comboform" type="text" name="configValue"
							data-copy-options="object.configValueOptions"
							data-options="required:true,editable:false,panelMaxHeight:'auto',separator:' | ',
							space:space,panelTemplate:'object-config-value',cls:'object-config-value'" />
					</div>
					<div class="col-md-1 control-label pl-clear">显示值</div>
					<div class="col-md-5 control-input"><input class="x-textbox" type="text" name="configText" data-options="editable:false,disabled:true,prompt:'对默认值的描述'"/></div>
				</div>

				<div class="form-group compact">
					<div class="col-md-1 control-label pl-clear">选项</div>
					<div class="col-md-5 control-input">
						<div class="row compact">
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="checkbox" name="visible" value="1" data-def-value="1" /></span>
									<div class="form-control">可见</div>
								</label>
							</div>
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="checkbox" name="editable" value="1" data-def-value="1" /></span>
									<div class="form-control">可编辑</div>
								</label>
							</div>
						</div>
					</div>
					<div class="col-md-1 control-label pl-clear">状态</div>
					<div class="col-md-5 control-input">
						<div class="row compact">
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="radio" name="usingState" value="ENABLED" data-def-value="ENABLED" /></span>
									<div class="form-control">启用</div>
								</label>
							</div>
							<div class="col-sm-6">
								<label class="input-group">
									<span class="input-group-addon"><input type="radio" name="usingState" value="DISABLED" /></span>
									<div class="form-control">禁用</div>
								</label>
							</div>
						</div>
					</div>
				</div>

			</dd>
		</form>
		<div class="dialog-button">
			<shiro:hasPermission name="root:develop && system-config:manager:create">
			<a href="javascript:void(0)" class="x-linkbutton show-operate show-create" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<shiro:hasPermission name="system-config:manager:update">
			<a href="javascript:void(0)" class="x-linkbutton show-operate show-update" data-options="xaction:'submit',iconCls:'fa fa-save'">保存</a>
			</shiro:hasPermission>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>

	<div class="x-dialog container-fluid" title="删除" data-options="xpopup:'delete',width:320,modal:true,iconCls:'fa fa-minus'">
		<form class="pure-box form-horizontal" method="POST" action="<base:url href='actions/config-item/manager/delete.json'/>">
			<dd>
				<span>确定要删除<abbr title="勾选指的是在第一列打勾，可以同时选中多行记录">勾选</abbr>的 <span class="records"></span> 条记录?</span>
			</dd>
		</form>
		<div class="dialog-button">
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'submit',iconCls:'fa fa-check',message:'删除'">确定</a>
			<a href="javascript:void(0)" class="x-linkbutton" data-options="xaction:'close',iconCls:'fa fa-close'">取消</a>
		</div>
	</div>

</div>

<script src="<base:url href='assets/pc/basedata/settings/combo.plugins.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.core.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.editor.text.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.editor.number.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.editor.enums.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.editor.object.js'/>"></script>
<script src="<base:url href='assets/pc/basedata/settings/config.item.js'/>"></script>

<%@ include file="config-common-template.jsp"%>
